import { useState, useEffect } from 'react'
import BusinessMap from '../../../../common/BusinessMap';
import PanelLeft from '../../../../common/PanelLeft';
import { Route, Switch, Redirect, useLocation, useHistory } from "react-router-dom";
import Fxjc from './Fxjc';
import BottomMenu from './BottomMenu';
import Sljc from './Sljc';
import Dizjc from './Dizjc';
import Dzjc from './Dzjc2';
import useBusinessMap from '../../../../common/BusinessMap/useBusinessMap';
import { createLayer, dataToFeature } from '../../../../../utils/helper/mapHelper';
import JcdApi from '../../../../../utils/apis/JcdApi';
import { Icon, Style } from 'ol/style';
import Toolbar from '../Yzt/Toolbar';
import LoopMsg from './LoopMsg';
import IconOnclickXq from './iconOnclickXq';
import jcyjContext from './jcyjContext';
import JcyjApi from '../../../../../utils/apis/JcyjApi';
import JzzyApi from '../../../../../utils/apis/JzzyApi';
import CztApi from '../../../../../utils/apis/CztApi';
import VideoMonitor from './VideoMonitorl';



const Content = props => {
    //回调每个xxDeatil中的yxList
    //  const [cbYxList, setCbYxList] = useState();
    return <Switch>
        <Redirect exact path="/main/jcyj" to={'/main/jcyj/fxjc'}></Redirect>
        <Route path={'/main/jcyj/fxjc'} component={Fxjc} ></Route>
        <Route path={'/main/jcyj/dzjc'} component={Dzjc} ></Route>
        <Route path={'/main/jcyj/dizjc'} component={Dizjc} ></Route>
        <Route path={'/main/jcyj/Sljc'} component={Sljc}></Route>


    </Switch>
}
export default function Jcyj(props) {
    const [iconOnclickXq, setIconOnclickXq] = useState()
    const [jcdListDates, setJcdListDates] = useState()
    const [jcDates, setJcDates] = useState({})
    //视频监控开关
    const [isClosed, setIsClosed] = useState(true);
    /* 
    --
    */
    const [typeda, setTypeda] = useState()
    /* 
    --
    */

    //地区降雨量
    const [jyl, setJyl] = useState()



    useEffect(() => {
        //console.log('jyl', jyl)
        JcyjApi.jcdList().then(resp => {
            setJcdListDates(resp)
        })
        // JcyjApi.sksq_findby().then(resp => {
        //     setSkDates(resp)
        //     //console.log('skDates',resp)
        // })

    }, [jyl])

    const [cbYxList, setCbYxList] = useState();



    //console.log(props)
    return <>
        {/* <BusinessMap >
            <LoopMsg />
            <Content />
            <BottomMenu />
           
        </BusinessMap> */}

        <jcyjContext.Provider value={{
            // setIconOnclickXq,
            // iconOnclickXq,
            jcdListDates,
            setJcdListDates,
            setJcDates,
            jcDates,
            typeda,
            setTypeda,
            cbYxList,
            setCbYxList,
            setJyl,
            setIsClosed,
            isClosed,
        }}>
            <BusinessMap jyl={jyl}>
                <LoopMsg />
                <Content />
                <BottomMenu cbYxList={cbYxList} />
                {/* {iconOnclickXq&&<IconOnclickXq  onClose={(e)=>{
                setIconOnclickXq(null)
            }}/>} */}
                {/* <Toolbar /> */}
                {/* <Fxpg /> */}
                {/* <Sljc /> */}
                {!isClosed&&<VideoMonitor/>}
            </BusinessMap>
        </jcyjContext.Provider>
    </>
}